home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Sources / FWPicShp.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  5.7 KB  |  205 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPicShp.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWPICSHP_H
  13. #include "FWPicShp.h"
  14. #endif
  15.  
  16. #ifndef FWGC_H
  17. #include "FWGC.h"
  18. #endif
  19.  
  20. #ifndef FWGRGLOB_H
  21. #include "FWGrGlob.h"
  22. #endif
  23.  
  24. #ifndef FWBMPSHP_H
  25. #include "FWBmpShp.h"
  26. #endif
  27.  
  28. #ifndef FWRECT_H
  29. #include "FWRect.h"
  30. #endif
  31.  
  32. #ifndef FWRASTER_H
  33. #include "FWRaster.h"
  34. #endif
  35.  
  36. // ----- Foundation Includes -----
  37.  
  38. #ifndef FWSTREAM_H
  39. #include "FWStream.h"
  40. #endif
  41.  
  42. #ifndef FWDEBUG_H
  43. #include "FWDebug.h"
  44. #endif
  45.  
  46. #ifndef FWMEMORY_H
  47. #include "FWMemory.h"
  48. #endif
  49.  
  50. //========================================================================================
  51. //    RunTime Info
  52. //========================================================================================
  53.  
  54. #if FW_LIB_EXPORT_PRAGMAS
  55. #pragma lib_export on
  56. #endif
  57.  
  58. #ifdef FW_BUILD_MAC
  59. #pragma segment FWGraphics_PictureShape
  60. #endif
  61.  
  62. FW_DEFINE_CLASS_M1(FW_CPictureShape, FW_CBoundedShape)
  63.  
  64. FW_REGISTER_ARCHIVABLE_CLASS(FW_LPictureShape, FW_CPictureShape, FW_CPictureShape::Read, FW_CShape::Write)
  65.  
  66. //========================================================================================
  67. //    class FW_CPictureShape
  68. //========================================================================================
  69.  
  70. //----------------------------------------------------------------------------------------
  71. //    FW_CPictureShape::FW_CPictureShape
  72. //----------------------------------------------------------------------------------------
  73.  
  74. FW_CPictureShape::FW_CPictureShape(FW_PPicture picture, const FW_CRect& rect) :
  75.     FW_CBoundedShape(rect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
  76.     fPicture(picture)
  77. {
  78.     FW_END_CONSTRUCTOR
  79. }
  80.  
  81. //----------------------------------------------------------------------------------------
  82. //    FW_CPictureShape::FW_CPictureShape
  83. //----------------------------------------------------------------------------------------
  84.  
  85. FW_CPictureShape::FW_CPictureShape(const FW_CPictureShape& other) :
  86.     FW_CBoundedShape(other),
  87.     fPicture(other.fPicture)
  88. {
  89.     FW_END_CONSTRUCTOR
  90. }
  91.  
  92. //----------------------------------------------------------------------------------------
  93. //    FW_CPictureShape::FW_CPictureShape
  94. //----------------------------------------------------------------------------------------
  95.  
  96. FW_CPictureShape::FW_CPictureShape(FW_CReadableStream& archive) :
  97.     FW_CBoundedShape(archive),
  98.     fPicture()
  99. {
  100.     archive >> fPicture;
  101.     
  102.     FW_END_CONSTRUCTOR
  103. }
  104.  
  105. //----------------------------------------------------------------------------------------
  106. //    FW_CPictureShape::~FW_CPictureShape
  107. //----------------------------------------------------------------------------------------
  108.  
  109. FW_CPictureShape::~FW_CPictureShape()
  110. {
  111.     FW_START_DESTRUCTOR
  112. }
  113.  
  114. //----------------------------------------------------------------------------------------
  115. //    FW_CPictureShape::operator=
  116. //----------------------------------------------------------------------------------------
  117.  
  118. FW_CPictureShape& FW_CPictureShape::operator=(const FW_CPictureShape& other)
  119. {
  120.     if (this != &other)
  121.     {
  122.         FW_CBoundedShape::operator=(other);
  123.     
  124.         fPicture = other.fPicture;
  125.     }
  126.     
  127.     return *this;
  128. }
  129.  
  130. //----------------------------------------------------------------------------------------
  131. //    FW_CPictureShape::Render
  132. //----------------------------------------------------------------------------------------
  133.  
  134. void FW_CPictureShape::Render(FW_CGraphicContext& gc) const
  135. {
  136.     gc.GetRasterizer()->RenderPicture(gc,
  137.                                         fPicture,
  138.                                         fRect,
  139.                                         GetRenderVerb());
  140. }
  141.  
  142. //----------------------------------------------------------------------------------------
  143. //    FW_CPictureShape::RenderPicture
  144. //----------------------------------------------------------------------------------------
  145.  
  146. void FW_CPictureShape::RenderPicture(FW_CGraphicContext& gc,
  147.                                     FW_PPicture picture,
  148.                                     const FW_CRect& dstRect)
  149. {
  150.     gc.GetRasterizer()->RenderPicture(gc,
  151.                                         picture,
  152.                                         dstRect,
  153.                                         FW_kFill);
  154. }
  155.  
  156. //----------------------------------------------------------------------------------------
  157. //    FW_CPictureShape::GetGeometry
  158. //----------------------------------------------------------------------------------------
  159.  
  160. void FW_CPictureShape::GetGeometry(FW_PPicture& picture, FW_CRect& dstRect) const
  161. {
  162.     picture = fPicture;
  163.     dstRect = fRect;
  164. }
  165.  
  166. //----------------------------------------------------------------------------------------
  167. //    FW_CPictureShape::SetGeometry
  168. //----------------------------------------------------------------------------------------
  169.  
  170. void FW_CPictureShape::SetGeometry(const FW_PPicture& picture, const FW_CRect& dstRect)
  171. {
  172.     fPicture = picture;
  173.     fRect = dstRect;
  174. }
  175.  
  176. //----------------------------------------------------------------------------------------
  177. //    FW_CPictureShape::Flatten
  178. //----------------------------------------------------------------------------------------
  179.  
  180. void FW_CPictureShape::Flatten(FW_CWritableStream& archive) const
  181. {
  182.     FW_CBoundedShape::Flatten(archive);
  183.  
  184.     fPicture->Flatten(archive);
  185. }
  186.  
  187. //----------------------------------------------------------------------------------------
  188. //    FW_CPictureShape::Copy
  189. //----------------------------------------------------------------------------------------
  190.  
  191. FW_CShape* FW_CPictureShape::Copy() const
  192. {
  193.     return FW_NEW(FW_CPictureShape, (*this));
  194. }
  195.  
  196. //----------------------------------------------------------------------------------------
  197. //    FW_CPictureShape::Read
  198. //----------------------------------------------------------------------------------------
  199.  
  200. void* FW_CPictureShape::Read(FW_CReadableStream& archive)
  201. {
  202.     return FW_NEW(FW_CPictureShape, (archive));
  203. }
  204.  
  205.